home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / justplay.lha / JustPlay / src / JustPlay.s < prev   
Text File  |  1995-07-07  |  39KB  |  2,034 lines

  1.  
  2.  
  3. **
  4. **    JustPlay 1.1
  5. **
  6. **    $VER: justplay.s (08.07.95)
  7. **
  8. **     written by Grzegorz Calkowski
  9. **
  10. **     (C) Copyright 1995 The Beet Research
  11. **
  12.  
  13. ;==============================================================================
  14.  
  15.         incdir    "asminc:"
  16.  
  17.         include    "exec/exec.i"        
  18.         include    "dos/dos.i"
  19.         include    "dos/dosextens.i"
  20.         include    "devices/audio.i"
  21.         include    "workbench/workbench.i"
  22.         include    "workbench/startup.i"
  23.         include    "libraries/xpk.i"
  24.  
  25.         include    "lvo30/exec_lib.i"
  26.         include    "lvo30/dos_lib.i"
  27.         include    "lvo30/intuition_lib.i"
  28.         include    "lvo30/icon_lib.i"
  29.         include    "lvo30/wb_lib.i"
  30.  
  31.         include    "gcmacros.i"
  32.  
  33. ;==============================================================================
  34.  
  35. VeryBegin    bra    Begin
  36.         dc.b    "$VER: JustPlay 1.1 by TBR (08.07.95)",0
  37.         even
  38.  
  39. ;==============================================================================
  40.  
  41. Begin        movem.l    d0-a6,-(sp)
  42.  
  43.         setexec
  44.         cmp    #36,LIB_VERSION(a6)
  45.         bhi.s    .kickok
  46.         st    KickFlag
  47.  
  48. .kickok        cla    a1
  49.         call    FindTask        ; get our task
  50.         move.l    d0,a4
  51.         tst.l    pr_CLI(a4)        ; start from cli?
  52.         bne.s    .itscli
  53.         sf    CLIFlag
  54.  
  55.         lea    pr_MsgPort(a4),a0    ; get the port
  56.         call    WaitPort
  57.         lea    pr_MsgPort(a4),a0
  58.         call    GetMsg
  59.         move.l    d0,WBMsg        ; store the message
  60.  
  61. .itscli        tst.b    KickFlag
  62.         bne    TooOldKick
  63.         
  64. ;==============================================================================
  65.  
  66.         setexec
  67.  
  68.         lea    RENDEZNAME(pc),a1
  69.         call    FindPort
  70.         tst.l    d0
  71.         beq.s    .norendez
  72.  
  73.         move.l    d0,a0
  74.         move.l    MP_SIGTASK(a0),a1
  75.         move.l    #SIGBREAKF_CTRL_C,d0
  76.         call    Signal
  77.         st    QuietFlag
  78.  
  79. .norendez    openlib    DOSName
  80.         move.l    d0,_DOSBase
  81.         beq    Exit
  82.         openlib    IntName
  83.         move.l    d0,_IntuitionBase
  84.         beq    CloseLibs
  85.         openlib    IconName
  86.         move.l    d0,_IconBase
  87.         beq    CloseLibs
  88.         openlib    WBName
  89.         move.l    d0,_WBBase
  90.         beq    CloseLibs
  91.  
  92. ;==============================================================================
  93.  
  94.         moveq    #DOS_FIB,d1
  95.         cld    d2
  96.         call    AllocDosObject,DOS
  97.         move.l    d0,FIB
  98.         beq    CloseLibs
  99.  
  100.         call    CreateMsgPort        ; create 'rendezvous' port
  101.         move.l    d0,RendezPort
  102.         beq    CleanUp
  103.         move.l    d0,a1
  104.         lea    RENDEZNAME(pc),a2
  105.         move.l    a2,LN_NAME(a1)
  106.         move.b    #5,LN_PRI(a1)
  107.         call    AddPort            ; make it public
  108.  
  109.         call    CreateMsgPort        ; create msgport for audio
  110.         move.l    d0,AudioPort
  111.         beq    CleanUp
  112.         
  113.         move.l    d0,a0
  114.         move.l    #ioa_SIZEOF,d0        ; size of AudioIO
  115.         call    CreateIORequest
  116.         move.l    d0,IORequest
  117.         beq    CleanUp
  118.         move.l    d0,a1
  119.  
  120.         move.l    #Channels,ioa_Data(a1)
  121.         move.l    #1,ioa_Length(a1)        
  122.         move    #0,ioa_AllocKey(a1)
  123.         move.b    #127,LN_PRI(a1)        
  124.         lea    AudioDevName(pc),a0
  125.         cld    d0
  126.         cld    d1        
  127.         call    OpenDevice
  128.         tst.l    d0
  129.         beq.s    .audiookay
  130.  
  131.         cla    a0
  132.         cla    a2
  133.         cla    a3
  134.         lea    CantOpenAd_es(pc),a1
  135.         cmp.l    #ADIOERR_ALLOCFAILED,d0
  136.         bne.s    .cantopenatall
  137.         lea    ChAlloc_es(pc),a1
  138. .cantopenatall    call    EasyRequestArgs,Intuition
  139.         cmp.l    #1,d0
  140.         beq.s    .audiookay
  141.         bra    CleanUp
  142.  
  143. .audiookay    bsr    setciaint
  144.         tst.l    ciaabase
  145.         bne.s    .ciaokay
  146.         cla    a0
  147.         cla    a2
  148.         cla    a3
  149.         lea    NoInt_es(pc),a1
  150.         call    EasyRequestArgs,Intuition
  151.         bra    CleanUp
  152.  
  153. ;==============================================================================
  154.  
  155. .ciaokay    setbase    DOS
  156.         move.l    WBMsg(pc),d0
  157.         bne.s    .itwaswb
  158.  
  159. *************
  160. * CLI
  161. *************
  162.         lea    TEMPLATE(pc),a0
  163.         move.l    a0,d1
  164.         lea    TmpVal(pc),a0
  165.         move.l    a0,d2
  166.         cld    d3
  167.         call    ReadArgs
  168.         move.l    d0,RDArgs
  169.         bne.s    .argsokay
  170.  
  171.         tst.b    QuietFlag        ; *QUIET*
  172.         bne    CleanUp
  173.         call    IoErr
  174.         move.l    d0,d1
  175.         lea    JustPlay_prompt(pc),a0
  176.         move.l    a0,d2
  177.         call    PrintFault
  178.         bra    CleanUp        
  179.  
  180. .argsokay    lea    TmpVal(pc),a2
  181.         move.l    4(a2),d0
  182.         beq.s    .nodmawait_1
  183.         move.l    d0,a0
  184.         move    2(a0),mt_dmadelay
  185. .nodmawait_1    move.l    (a2),d1
  186.         move.l    d1,FName
  187.         move.l    #ACCESS_READ,d2
  188.         call     Lock
  189.         move.l    d0,FLock
  190.         bne.w    .locked
  191.         bsr    CantRead
  192.         bra    CleanUp
  193.  
  194. *************
  195. * WB
  196. *************
  197.  
  198. .itwaswb    move.l    d0,a2
  199.         cmp.l    #2,sm_NumArgs(a2)
  200.         beq.s    .gotarg
  201.         bhi.s    .noextsel
  202.  
  203.         tst.b    QuietFlag
  204.         bne    CleanUp            ;*QUIET*
  205.  
  206.         cla    a0
  207.         cla    a2
  208.         cla    a3
  209.         lea    NoArg_es(pc),a1
  210.         call    EasyRequestArgs,Intuition
  211.         bra    CleanUp
  212.  
  213. .noextsel    move.l    a2,-(sp)
  214.         cla    a0
  215.         cla    a2
  216.         cla    a3
  217.         lea    NoExtSel_es(pc),a1
  218.         call    EasyRequestArgs,Intuition
  219.         move.l    (sp)+,a2
  220.  
  221. .gotarg        move.l    sm_ArgList(a2),a2
  222.         move.l    wa_Lock(a2),d1
  223.         call    CurrentDir
  224.         move.l    wa_Name(a2),a0
  225.         setbase    Icon
  226.         call    GetDiskObject
  227.         move.l    d0,DiskObj
  228.         bne.s    .goticon
  229.  
  230.         cla    a0
  231.         cla    a2
  232.         cla    a3
  233.         lea    NoIcon_es(pc),a1
  234.         call    EasyRequestArgs,Intuition
  235.         bra    CleanUp
  236.  
  237. .goticon    move.l    d0,a0
  238.         move.l    do_ToolTypes(a0),a0
  239.         move.l    a0,a5
  240.         lea    DMAWAIT_tt(pc),a1
  241.         call    FindToolType
  242.         tst.l    d0
  243.         beq.s    .nodmawait
  244.         move.l    d0,d1
  245.         move.l    #TmpVal,d2
  246.         call    StrToLong,DOS
  247.         tst.l    d0
  248.         bmi.s    .nodmawait
  249.         tst.l    TmpVal
  250.         beq.s    .nodmawait
  251.         move    TmpVal+2(pc),mt_dmadelay
  252.  
  253. .nodmawait    move.l    a5,a0
  254.         lea    ICONTEXT_tt(pc),a1
  255.         call    FindToolType
  256.         tst.l    d0
  257.         beq.s    .noicontext
  258.         move.l    d0,IconText
  259.  
  260. .noicontext    move.l    a5,a0
  261.         lea    ICONXPOS_tt(pc),a1
  262.         call    FindToolType
  263.         tst.l    d0
  264.         beq.s    .noxpos
  265.         move.l    d0,d1
  266.         move.l    #TmpVal,d2
  267.         call    StrToLong,DOS
  268.         tst.l    d0
  269.         bmi.s    .noxpos
  270.         tst.l    TmpVal
  271.         beq.s    .noxpos
  272.         move.l    TmpVal(pc),IconXPos
  273.  
  274. .noxpos        move.l    a5,a0
  275.         lea    ICONYPOS_tt(pc),a1
  276.         call    FindToolType
  277.         tst.l    d0
  278.         beq.s    .getarg
  279.         move.l    d0,d1
  280.         move.l    #TmpVal,d2
  281.         call    StrToLong,DOS
  282.         tst.l    d0
  283.         bmi.s    .getarg
  284.         tst.l    TmpVal
  285.         beq.s    .getarg
  286.         move.l    TmpVal(pc),IconYPos
  287.  
  288. .getarg        setbase    DOS
  289.         addq.l    #8,a2
  290.         move.l    wa_Lock(a2),d1
  291.         call    CurrentDir
  292.         move.l    wa_Name(a2),d1
  293.         move.l    d1,FName
  294.         move.l    #ACCESS_READ,d2
  295.         call     Lock
  296.         move.l    d0,FLock
  297.         bne.s    .locked
  298.         bsr    CantRead
  299.         bra    CleanUp
  300. ************
  301. .locked        move.l    d0,d1
  302.         move.l    FIB(pc),d2
  303.         move.l    d2,a2
  304.         call    Examine
  305.         move.l    d0,d7            ;save d0
  306.         move.l    FLock(pc),d1
  307.         call    UnLock
  308.         tst.l    d7
  309.         bne.s    .examok
  310.         bsr    CantRead
  311.         bra    CleanUp
  312.  
  313. .examok        move.l    fib_Size(a2),d0
  314.         addq.l    #4,d0            ; if not - causes Mungwall hit
  315.         move.l    d0,FileSize
  316.         moveq    #MEMF_CHIP,d1
  317.         sys    AllocMem
  318.         move.l    d0,FileBuf
  319.         bne.s    .memok
  320.         cla    a0
  321.         cla    a2
  322.         cla    a3
  323.         lea    NoMem_es(pc),a1
  324.         call    EasyRequestArgs,Intuition
  325.         bra    CleanUp
  326.  
  327. .memok        move.l    FName(pc),d1
  328.         move.l    #MODE_OLDFILE,d2
  329.         call    Open
  330.         move.l    d0,FHandle
  331.         bne.s    .opened
  332.         bsr    CantRead
  333.         bra    CleanUp
  334.  
  335. .opened        move.l    d0,d1
  336.         move.l    FileBuf(pc),d2
  337.         move.l    #512*3,d3
  338.         call    Read
  339.         tst.l    d0
  340.         bpl.s    .read1ok
  341.         bsr    CantRead
  342.         move.l    FHandle(pc),d1
  343.         call    Close    
  344.         bra    CleanUp
  345.  
  346. .read1ok    move.l    FileBuf(pc),a0
  347.         cmp.l    #'XPKF',(a0)
  348.         beq.s    .xpacked
  349.         cmp.l    #'PP20',(a0)        ; Decrunch PP (v1.1)
  350.         beq.s    .xpacked
  351.         cmp.l    #'M.K.',1080(a0)
  352.         beq.w    .itismod
  353.         cmp.l    #'FLT4',1080(a0)
  354.         beq.w    .itismod
  355.         
  356.         cla    a0
  357.         cla    a2
  358.         cla    a3
  359.         lea    NoMod_es(pc),a1
  360.         call    EasyRequestArgs,Intuition
  361.         tst.l    d0
  362.         bne.w    .itismod
  363.         move.l    FHandle(pc),d1
  364.         call    Close
  365.         bra    .freeit
  366.  
  367. ;==============================================================================
  368.  
  369. .xpacked    move.l    FHandle(pc),d1
  370.         call    Close
  371.         move.l    FileBuf(pc),a1
  372.         move.l    FileSize(pc),d0
  373.         setexec
  374.         call    FreeMem
  375.  
  376.         openlib    XPKName
  377.         tst.l    d0
  378.         beq.s    .noxpk
  379.         move.l    d0,a6
  380.  
  381.         lea    XPK_tags(pc),a0
  382.         move.l    FName(pc),ti_Data(a0)
  383.         call    XpkUnpack
  384.         move.l    d0,d7
  385.         move.l    a6,a1
  386.         setexec
  387.         call    CloseLibrary
  388.         tst.l    d7
  389.         beq    .soplay
  390.  
  391.         cla    a0
  392.         cla    a2
  393.         cla    a3
  394.         lea    XPKerr_es(pc),a1
  395.         call    EasyRequestArgs,Intuition
  396.         bra    CleanUp
  397.         
  398. .noxpk        cla    a0
  399.         cla    a2
  400.         cla    a3
  401.         lea    NoXPK_es(pc),a1
  402.         call    EasyRequestArgs,Intuition
  403.         bra    CleanUp
  404.  
  405. ;==============================================================================
  406.  
  407. .itismod    move.l    FHandle(pc),d1
  408.         move.l    FileBuf(pc),d2
  409.         add.l    #512*3,d2
  410.         move.l    FileSize(pc),d3
  411.         sub.l    #512*3,d3
  412.         call    Read
  413.         move.l    d0,d7
  414.         move.l    FHandle(pc),d1
  415.         call    Close    
  416.         tst.l    d7
  417.         bpl.s    .soplay
  418.         bsr    CantRead
  419.         bra    CleanUp
  420.  
  421. ;==============================================================================
  422.  
  423. .soplay        tst.b    CLIFlag
  424.         bne    .noappicon
  425.  
  426.         sys    CreateMsgPort
  427.         move.l    d0,AppIconPort
  428.         beq    .noappicon
  429.         move.l    d0,a1
  430.         move.l    IconText(pc),a0
  431.         move.l    DiskObj(pc),a3
  432.         move.l    IconXPos(pc),do_CurrentX(a3)
  433.         move.l    IconYPos(pc),do_CurrentY(a3)
  434.         cld    d0
  435.         cld    d1
  436.         cla    a2
  437.         cla    a4
  438.         call    AddAppIconA,WB
  439.         move.l    d0,AppIconPtr
  440.         beq.w    .noappicon
  441.  
  442.         bsr    mt_init
  443.         st    mt_enable
  444.         setexec
  445.         cld    d7            ; will be "exit flag"
  446.  
  447.         move.l    AppIconPort(pc),a0
  448.         moveq    #1,d0
  449.         cld    d1
  450.         move.b    MP_SIGBIT(a0),d1
  451.         lsl.l    d1,d0            ; AppIconPort signal bit
  452.         move.l    d0,AppIconPortF
  453.         move.b    d1,AppIconPortB
  454.  
  455. .waitloop    tst.b    d7
  456.         bne.s    .stopit
  457.  
  458.         move.l    AppIconPortF(pc),d0
  459.         or.l    #SIGBREAKF_CTRL_C,d0
  460.         call    Wait
  461.         btst    #SIGBREAKB_CTRL_C,d0
  462.         bne.s    .flushmsgs
  463.  
  464.         cld    d1
  465.         move.b    AppIconPortB(pc),d1
  466.         btst    d1,d0
  467.         beq.s    .waitloop        ; 0 means no AppIconPort
  468.  
  469. .nextmsg    move.l    AppIconPort(pc),a0
  470.         call    GetMsg
  471.         tst.l    d0
  472.         beq.s    .waitloop
  473.         move.l    d0,a1
  474.         cmp    #MTYPE_APPICON,am_Type(a1)
  475.         bne.s    .reply
  476.         tst.l    am_NumArgs(a1)        
  477.         bne.s    .getlost
  478.         st    d7
  479.         bra.s    .reply
  480. .getlost    move.l    a1,d6
  481.         cla    a0
  482.         cla    a2
  483.         cla    a3
  484.         lea    GetLost_es(pc),a1
  485.         call    EasyRequestArgs,Intuition
  486.         move.l    d6,a1
  487. .reply        call    ReplyMsg
  488.         bra.s    .nextmsg
  489.  
  490. .flushmsgs    move.l    AppIconPort(pc),a0
  491.         call    GetMsg
  492.         tst.l    d0
  493.         beq.s    .stopit
  494.         move.l    d0,a1
  495.         call    ReplyMsg
  496.         bra.s    .flushmsgs
  497.  
  498. .stopit        move.l    AppIconPtr(pc),a0
  499.         setbase    WB
  500.         call    RemoveAppIcon
  501.         move.l    AppIconPort(pc),a0
  502.         setexec
  503.         call    DeleteMsgPort
  504.         bsr    mt_end
  505.         bra.s    .freeit
  506.  
  507. ;==============================================================================
  508.  
  509. .noappicon    bsr    mt_init
  510.         st    mt_enable
  511.  
  512.         setexec
  513.         move.l    #SIGBREAKF_CTRL_C,d0
  514.         call    Wait
  515.         bsr    mt_end
  516.  
  517. ;==============================================================================
  518.  
  519. .freeit        setexec
  520.         move.l    FileBuf(pc),a1
  521.         move.l    FileSize(pc),d0
  522.         call    FreeMem
  523.         
  524. ;==============================================================================
  525.  
  526. CleanUp        tst.l    ciaabase
  527.         beq.s    .noint
  528.         bsr    resetciaint
  529.  
  530. .noint        move.l    DiskObj(pc),d0
  531.         beq.s    .nodiskobj
  532.         setbase    Icon
  533.         move.l    d0,a0
  534.         call    FreeDiskObject        
  535.  
  536. .nodiskobj    setexec
  537.         move.l    IORequest(pc),d0
  538.         beq.s    .nodev
  539.         move.l    d0,a1
  540.         call    CloseDevice        
  541.  
  542. .nodev        move.l    IORequest(pc),d0
  543.         beq.s    .noioreq
  544.         move.l    d0,a0
  545.         call    DeleteIORequest
  546.  
  547. .noioreq    move.l    RendezPort(pc),d7
  548.         beq.s    .norendezport
  549.         move.l    d7,a1
  550.         call    RemPort
  551.         move.l    d7,a0
  552.         call    DeleteMsgPort
  553.  
  554. .norendezport    move.l    AudioPort(pc),d0
  555.         beq.s    .noaudioport
  556.         move.l    d0,a0
  557.         call    DeleteMsgPort
  558.  
  559. .noaudioport    setbase    DOS                ;DOS now
  560.         move.l    FIB(pc),d2
  561.         beq.s    .nofib
  562.         moveq    #DOS_FIB,d1
  563.         call    FreeDosObject
  564. .nofib
  565.         move.l    RDArgs(pc),d1
  566.         beq.s    .nordargs
  567.         call    FreeArgs
  568. .nordargs
  569.  
  570. CloseLibs    setexec
  571.         clslib    DOS
  572.         clslib    Intuition
  573.         clslib    Icon
  574.         clslib    WB
  575.  
  576. ;==============================================================================
  577.  
  578. Exit        move.l    WBMsg(pc),d0
  579.         beq.s    .nowb
  580.         move.l    d0,a1
  581.         setexec
  582.         call    Forbid            ; NOTE! NO Permit needed!
  583.         call    ReplyMsg
  584. .nowb        movem.l    (sp)+,d0-a6
  585.         moveq    #0,d0
  586.         rts
  587.  
  588. ;==============================================================================
  589.  
  590. TooOldKick    openlib    DOSName
  591.         move.l    d0,a6
  592.         tst.l    d0
  593.         beq    Exit            ; no dos...
  594.         move.l    d0,a6
  595.         move.l    #.outwindow,d1        ; we wanna window
  596.         move.l    #MODE_NEWFILE,d2
  597.         call    Open
  598.         tst.l    d0            ; couldn't open?
  599.         beq.s    .clsdos
  600.         move.l    d0,d7            ; store handle in d7
  601.         move.l    d7,d1
  602.         move.l    #.kicktxt,d2        ; text to display
  603.         move.l    #.keybuf-.kicktxt,d3
  604.         call    Write
  605.         move.l    d7,d1
  606.         move.l    #.keybuf,d2
  607.         moveq    #1,d3
  608.         call    Read            ; read any key
  609.         move.l    d7,d1
  610.         call    Close
  611. .clsdos        move.l    a6,a1
  612.         setexec
  613.         call    CloseLibrary
  614.         bra    Exit
  615.             
  616.  
  617. .outwindow    dc.b    "RAW:40/40/350/60/JustPlay v1.1",0
  618. .kicktxt    dc.b    10,"Required at least Kickstart V37.",10,10
  619.         dc.b    "Press any key to continue... "
  620. .keybuf        dc.b    0
  621.         even
  622.  
  623. ;==============================================================================
  624.  
  625. CantRead    cla    a0
  626.         cla    a2
  627.         cla    a3
  628.         lea    CantRead_es(pc),a1
  629.         call    EasyRequestArgs,Intuition
  630.         rts
  631.  
  632. ;==============================================================================
  633.  
  634. _DOSBase    dc.l    0
  635. _IntuitionBase    dc.l    0
  636. _IconBase    dc.l    0
  637. _WBBase        dc.l    0
  638.  
  639. WBMsg        dc.l    0
  640. AudioPort    dc.l    0
  641. IORequest    dc.l    0
  642. FName        dc.l    0
  643. FHandle        dc.l    0
  644. FLock        dc.l    0
  645. FIB        dc.l    0
  646. DiskObj        dc.l    0
  647. AppIconPtr    dc.l    0
  648. AppIconPort    dc.l    0
  649. AppIconPortF    dc.l    0
  650. RDArgs        dc.l    0
  651. RendezPort    dc.l    0
  652.  
  653. FileSize    dc.l    0
  654. FileBuf        dc.l    0
  655.  
  656. IconText    dc.l    Stop_txt
  657. IconXPos    dc.l    NO_ICON_POSITION
  658. IconYPos    dc.l    NO_ICON_POSITION
  659.  
  660. TmpVal        dc.l    0,0
  661.  
  662. XPK_tags    dc.l    XPK_InName,0
  663.         dc.l    XPK_GetOutBuf,FileBuf
  664.         dc.l    XPK_GetOutBufLen,FileSize
  665.         dc.l    XPK_GetOutLen,TmpVal
  666.         dc.l    XPK_OutMemType,MEMF_CHIP
  667.         dc.l    TAG_DONE
  668.  
  669. AppIconPortB    dc.b    0
  670.  
  671. Channels    dc.b    %1111
  672. CLIFlag        dc.b    1
  673. KickFlag    dc.b    0
  674. QuietFlag    dc.b    0
  675. XPKFlag        dc.b    0
  676.  
  677. DOSName        dc.b    "dos.library",0
  678. IntName        dc.b    "intuition.library",0
  679. IconName    dc.b    "icon.library",0
  680. WBName        dc.b    "workbench.library",0
  681. XPKName        dc.b    "xpkmaster.library",0
  682. AudioDevName    dc.b    "audio.device",0
  683.         even
  684.  
  685. ;==============================================================================
  686.  
  687. GetLost_es    dc.l    EasyStruct_SIZEOF,0
  688.         dc.l    JustPlay_txt,.text,.gads
  689. .text        dc.b    "JustPlay v1.1",10
  690.         dc.b    "by Grzegorz Calkowski",10
  691.         dc.b    "© 1995 The Beet Research",0
  692. .gads        dc.b    "Nice to know",0
  693.  
  694. NoIcon_es    dc.l    EasyStruct_SIZEOF,0
  695.         dc.l    JustPlay_txt,.text,.gads
  696. .text        dc.b    "Can't get icon! Failed...",0
  697. .gads        dc.b    "I'll fix it",0
  698.  
  699. ChAlloc_es    dc.l    EasyStruct_SIZEOF,0
  700.         dc.l    JustPlay_txt,.text,.gads
  701. .text        dc.b    "Can't allocate audio channels!",0
  702. .gads        dc.b    "Don't care|Cancel",0,0
  703.  
  704. CantOpenAd_es    dc.l    EasyStruct_SIZEOF,0
  705.         dc.l    JustPlay_txt,.text,.gads
  706. .text        dc.b    "Can't open audio.device!",0
  707. .gads        dc.b    "Pity",0
  708.  
  709. NoArg_es    dc.l    EasyStruct_SIZEOF,0
  710.         dc.l    JustPlay_txt,.text,.gads
  711. .text        dc.b    "No module given.",0
  712. .gads        dc.b    "Sure",0
  713.  
  714. NoExtSel_es    dc.l    EasyStruct_SIZEOF,0
  715.         dc.l    JustPlay_txt,.text,.gads
  716. .text        dc.b    "No extended select allowed:",10
  717.         dc.b    "Only first module will be played.",0
  718. .gads        dc.b    "I see",0
  719.  
  720. NoMod_es    dc.l    EasyStruct_SIZEOF,0
  721.         dc.l    JustPlay_txt,.text,.gads
  722. .text        dc.b    "The file is NOT an ordinary module.",10
  723.         dc.b    "Only NT/PT/STR-modules supported.",0
  724. .gads        dc.b    "Play anyway|Cancel",0,0
  725.         
  726. NoInt_es    dc.l    EasyStruct_SIZEOF,0
  727.         dc.l    JustPlay_txt,.text,.gads
  728. .text        dc.b    "No CIA interrupt available.",0
  729. .gads        dc.b    "Hmmm",0,0
  730.  
  731. NoMem_es    dc.l    EasyStruct_SIZEOF,0
  732.         dc.l    JustPlay_txt,.text,.gads
  733. .text        dc.b    "Insufficient memory.",0
  734. .gads        dc.b    "Hard to hear",0
  735.  
  736. CantRead_es    dc.l    EasyStruct_SIZEOF,0
  737.         dc.l    JustPlay_txt,.text,.gads
  738. .text        dc.b    "Can't read the file!",0
  739. .gads        dc.b    "Bye",0,0
  740.  
  741. NoXPK_es    dc.l    EasyStruct_SIZEOF,0
  742.         dc.l    JustPlay_txt,.text,.gads
  743. .text        dc.b    "No xpkmaster.library found.",10
  744.         dc.b    "File can't be decrunched.",0
  745. .gads        dc.b    "I see",0
  746.  
  747. XPKerr_es    dc.l    EasyStruct_SIZEOF,0
  748.         dc.l    JustPlay_txt,.text,.gads
  749. .text        dc.b    "Can't read/decrunch the file!",0
  750. .gads        dc.b    "Bye",0
  751.  
  752. ;==============================================================================
  753.  
  754. TEMPLATE    dc.b    "MODULE/A,DMAWAIT/K/N",0
  755.  
  756. DMAWAIT_tt    dc.b    "DMAWAIT",0
  757. ICONTEXT_tt    dc.b    "ICONTEXT",0
  758. ICONXPOS_tt    dc.b    "ICONXPOS",0
  759. ICONYPOS_tt    dc.b    "ICONYPOS",0
  760.  
  761. RENDEZNAME    dc.b    "JustPlay.rendezvous",0
  762.  
  763. ;==============================================================================
  764.  
  765. JustPlay_prompt    dc.b    "JustPlay",0
  766. JustPlay_txt    dc.b    "JustPlay v1.1",0
  767. Stop_txt    dc.b    "STOP!",0
  768.  
  769. KickOld_msg    dc.b    "Required at least Kickstart V37.",10,0
  770. KickOld_msg_len    equ    *-KickOld_msg
  771.  
  772.         cnop    0,4
  773.  
  774. ;==============================================================================
  775.  
  776. ;**************************************************
  777. ;*    ----- Protracker V2.1A Playroutine -----    *
  778. ;* Peter "CRAYON" Hanning / Mushroom Studios 1992 *
  779. ;*    Vinterstigen 12, 14440 Ronninge, Sweden     *
  780. ;**************************************************
  781.  
  782. ;---- cia interrupt ----
  783.  
  784. addicrvector    =   -6
  785. remicrvector    =  -12
  786. lvoopenresource    = -498
  787. lvoopenlibrary     = -552
  788. lvocloselibrary    = -414
  789. lvodelay    = -198
  790.  
  791. ciatalo = $400
  792. ciatahi = $500
  793. ciatblo = $600
  794. ciatbhi = $700
  795. ciacra  = $e00
  796. ciacrb  = $f00
  797.  
  798. setciaint
  799.     moveq    #2,d6
  800.     lea    $bfd000,a5
  801.     move.b    #'b',ciaaname+3
  802. setcialoop
  803.     moveq    #0,d0
  804.     lea    ciaaname(pc),a1
  805.     move.l    4.w,a6
  806.     jsr    lvoopenresource(a6)
  807.     move.l    d0,ciaabase
  808.     beq    mt_return
  809.  
  810.     lea    gfxname(pc),a1
  811.     moveq    #0,d0
  812.     jsr    lvoopenlibrary(a6)
  813.     tst.l    d0
  814.     beq    resetciaint
  815.     move.l    d0,a1
  816.     move.w    206(a1),d0    ; displayflags
  817.     btst    #2,d0        ; pal?
  818.     beq.s    wasntsc
  819.     move.l    #1773447,d7 ; pal
  820.     bra.s    sciask
  821. wasntsc    move.l    #1789773,d7 ; ntsc
  822. sciask    move.l    d7,timervalue
  823.     divu    #125,d7 ; default to normal 50 hz timer
  824.     jsr    lvocloselibrary(a6)
  825.  
  826.     move.l    ciaabase(pc),a6
  827.     cmp.w    #2,d6
  828.     beq.s    trytimera
  829. trytimerb
  830.     lea    musicintserver(pc),a1
  831.     moveq    #1,d0    ; bit 1: timer b
  832.     jsr    addicrvector(a6)
  833.     move.l    #1,timerflag
  834.     tst.l    d0
  835.     bne.s    ciaerror
  836.     move.l    a5,ciaaaddr
  837.     move.b    d7,ciatblo(a5)
  838.     lsr.w    #8,d7
  839.     move.b    d7,ciatbhi(a5)
  840.     bset    #0,ciacrb(a5)
  841.     rts
  842.  
  843. trytimera
  844.     lea    musicintserver(pc),a1
  845.     moveq    #0,d0    ; bit 0: timer a
  846.     jsr    addicrvector(a6)
  847.     clr.l    timerflag
  848.     tst.l    d0
  849.     bne.s    ciaerror
  850.     move.l    a5,ciaaaddr
  851.     move.b    d7,ciatalo(a5)
  852.     lsr.w    #8,d7
  853.     move.b    d7,ciatahi(a5)
  854.     bset    #0,ciacra(a5)
  855.     rts
  856.  
  857. ciaerror
  858.     move.b    #'a',ciaaname+3
  859.     lea    $bfe001,a5
  860.     subq.w    #1,d6
  861.     bne    setcialoop
  862.     clr.l    ciaabase
  863.     rts
  864.  
  865. resetciaint
  866.     move.l    ciaabase(pc),d0
  867.     beq    mt_return
  868.     clr.l    ciaabase
  869.     move.l    d0,a6
  870.     move.l    ciaaaddr(pc),a5
  871.     tst.l    timerflag
  872.     beq.s    restimera
  873.  
  874.     bclr    #0,ciacrb(a5)
  875.     moveq    #1,d0
  876.     bra.s    remint
  877.  
  878. restimera
  879.     bclr    #0,ciacra(a5)
  880.     moveq    #0,d0
  881. remint    lea    musicintserver(pc),a1
  882.     moveq    #0,d0
  883.     jsr    remicrvector(a6)
  884.     rts
  885.  
  886. ;---- tempo ----
  887.  
  888. settempo
  889.     move.l    ciaabase(pc),d2
  890.     beq    mt_return
  891.     cmp.w    #32,d0
  892.     bhs.s    setemsk
  893.     moveq    #32,d0
  894. setemsk    move.w    d0,realtempo
  895.     move.l    timervalue(pc),d2
  896.     divu    d0,d2
  897.     move.l    ciaaaddr(pc),a4
  898.     move.l    timerflag(pc),d0
  899.     beq.s    settema
  900.     move.b    d2,ciatblo(a4)
  901.     lsr.w    #8,d2
  902.     move.b    d2,ciatbhi(a4)
  903.     rts
  904.  
  905. settema    move.b    d2,ciatalo(a4)
  906.     lsr.w    #8,d2
  907.     move.b    d2,ciatahi(a4)
  908.     rts
  909.  
  910. realtempo    dc.w 125
  911. ciaaaddr    dc.l 0
  912. ciaaname    dc.b "ciaa.resource",0
  913. ciaabase    dc.l 0
  914. timerflag    dc.l 0
  915. timervalue    dc.l 0
  916. gfxname        dc.b "graphics.library",0,0
  917.  
  918. musicintserver
  919.     dc.l 0,0
  920.     dc.b 2,5 ; type, priority
  921.     dc.l musintname
  922.     dc.l 0,mt_music
  923.  
  924. musintname    dc.b "protracker musicint",0
  925.  
  926. ;---- playroutine ----
  927.  
  928. n_note        equ    0  ; w
  929. n_cmd        equ    2  ; w
  930. n_cmdlo        equ    3  ; b
  931. n_start        equ    4  ; l
  932. n_length    equ    8  ; w
  933. n_loopstart    equ    10 ; l
  934. n_replen    equ    14 ; w
  935. n_period    equ    16 ; w
  936. n_finetune    equ    18 ; b
  937. n_volume    equ    19 ; b
  938. n_dmabit    equ    20 ; w
  939. n_toneportdirec    equ    22 ; b
  940. n_toneportspeed    equ    23 ; b
  941. n_wantedperiod    equ    24 ; w
  942. n_vibratocmd    equ    26 ; b
  943. n_vibratopos    equ    27 ; b
  944. n_tremolocmd    equ    28 ; b
  945. n_tremolopos    equ    29 ; b
  946. n_wavecontrol    equ    30 ; b
  947. n_glissfunk    equ    31 ; b
  948. n_sampleoffset    equ    32 ; b
  949. n_pattpos    equ    33 ; b
  950. n_loopcount    equ    34 ; b
  951. n_funkoffset    equ    35 ; b
  952. n_wavestart    equ    36 ; l
  953. n_reallength    equ    40 ; w
  954.  
  955. mt_init    move.l    FileBuf(pc),a0
  956.     move.l    a0,mt_songdataptr
  957.     move.l    a0,a1
  958.     lea    952(a1),a1
  959.     moveq    #127,d0
  960.     moveq    #0,d1
  961. mtloop    move.l    d1,d2
  962.     subq.w    #1,d0
  963. mtloop2    move.b    (a1)+,d1
  964.     cmp.b    d2,d1
  965.     bgt.s    mtloop
  966.     dbra    d0,mtloop2
  967.     addq.b    #1,d2
  968.             
  969.     lea    mt_samplestarts(pc),a1
  970.     asl.l    #8,d2
  971.     asl.l    #2,d2
  972.     add.l    #1084,d2
  973.     add.l    a0,d2
  974.     move.l    d2,a2
  975.     moveq    #30,d0
  976. mtloop3    clr.l    (a2)
  977.     move.l    a2,(a1)+
  978.     moveq    #0,d1
  979.     move.w    42(a0),d1
  980.     asl.l    #1,d1
  981.     add.l    d1,a2
  982.     add.l    #30,a0
  983.     dbra    d0,mtloop3
  984.  
  985.     or.b    #2,$bfe001
  986.     move.b    #6,mt_speed
  987.     clr.b    mt_counter
  988.     clr.b    mt_songpos
  989.     clr.w    mt_patternpos
  990. mt_end    sf    mt_enable
  991.     lea    $dff000,a0
  992.     clr.w    $a8(a0)
  993.     clr.w    $b8(a0)
  994.     clr.w    $c8(a0)
  995.     clr.w    $d8(a0)
  996.     move.w    #$f,$dff096
  997.     rts
  998.  
  999. mt_music
  1000.     movem.l    d0-d4/a0-a6,-(sp)
  1001.     tst.b    mt_enable
  1002.     beq    mt_exit
  1003.     addq.b    #1,mt_counter
  1004.     move.b    mt_counter(pc),d0
  1005.     cmp.b    mt_speed(pc),d0
  1006.     blo.s    mt_nonewnote
  1007.     clr.b    mt_counter
  1008.     tst.b    mt_pattdeltime2
  1009.     beq.s    mt_getnewnote
  1010.     bsr.s    mt_nonewallchannels
  1011.     bra    mt_dskip
  1012.  
  1013. mt_nonewnote
  1014.     bsr.s    mt_nonewallchannels
  1015.     bra    mt_nonewposyet
  1016.  
  1017. mt_nonewallchannels
  1018.     lea    $dff0a0,a5
  1019.     lea    mt_chan1temp(pc),a6
  1020.     bsr    mt_checkefx
  1021.     lea    $dff0b0,a5
  1022.     lea    mt_chan2temp(pc),a6
  1023.     bsr    mt_checkefx
  1024.     lea    $dff0c0,a5
  1025.     lea    mt_chan3temp(pc),a6
  1026.     bsr    mt_checkefx
  1027.     lea    $dff0d0,a5
  1028.     lea    mt_chan4temp(pc),a6
  1029.     bra    mt_checkefx
  1030.  
  1031. mt_getnewnote
  1032.     move.l    mt_songdataptr(pc),a0
  1033.     lea    12(a0),a3
  1034.     lea    952(a0),a2    ;pattpo
  1035.     lea    1084(a0),a0    ;patterndata
  1036.     moveq    #0,d0
  1037.     moveq    #0,d1
  1038.     move.b    mt_songpos(pc),d0
  1039.     move.b    (a2,d0.w),d1
  1040.     asl.l    #8,d1
  1041.     asl.l    #2,d1
  1042.     add.w    mt_patternpos(pc),d1
  1043.     clr.w    mt_dmacontemp
  1044.  
  1045.     lea    $dff0a0,a5
  1046.     lea    mt_chan1temp(pc),a6
  1047.     bsr.s    mt_playvoice
  1048.     lea    $dff0b0,a5
  1049.     lea    mt_chan2temp(pc),a6
  1050.     bsr.s    mt_playvoice
  1051.     lea    $dff0c0,a5
  1052.     lea    mt_chan3temp(pc),a6
  1053.     bsr.s    mt_playvoice
  1054.     lea    $dff0d0,a5
  1055.     lea    mt_chan4temp(pc),a6
  1056.     bsr.s    mt_playvoice
  1057.     bra    mt_setdma
  1058.  
  1059. mt_playvoice
  1060.     tst.l    (a6)
  1061.     bne.s    mt_plvskip
  1062.     bsr    mt_pernop
  1063. mt_plvskip
  1064.     move.l    (a0,d1.l),(a6)
  1065.     addq.l    #4,d1
  1066.     moveq    #0,d2
  1067.     move.b    n_cmd(a6),d2
  1068.     and.b    #$f0,d2
  1069.     lsr.b    #4,d2
  1070.     move.b    (a6),d0
  1071.     and.b    #$f0,d0
  1072.     or.b    d0,d2
  1073.     tst.b    d2
  1074.     beq    mt_setregs
  1075.     moveq    #0,d3
  1076.     lea    mt_samplestarts(pc),a1
  1077.     move    d2,d4
  1078.     subq.l    #1,d2
  1079.     asl.l    #2,d2
  1080.     mulu    #30,d4
  1081.     move.l    (a1,d2.l),n_start(a6)
  1082.     move.w    (a3,d4.l),n_length(a6)
  1083.     move.w    (a3,d4.l),n_reallength(a6)
  1084.     move.b    2(a3,d4.l),n_finetune(a6)
  1085.     move.b    3(a3,d4.l),n_volume(a6)
  1086.     move.w    4(a3,d4.l),d3 ; get repeat
  1087.     tst.w    d3
  1088.     beq.s    mt_noloop
  1089.     move.l    n_start(a6),d2    ; get start
  1090.     asl.w    #1,d3
  1091.     add.l    d3,d2        ; add repeat
  1092.     move.l    d2,n_loopstart(a6)
  1093.     move.l    d2,n_wavestart(a6)
  1094.     move.w    4(a3,d4.l),d0    ; get repeat
  1095.     add.w    6(a3,d4.l),d0    ; add replen
  1096.     move.w    d0,n_length(a6)
  1097.     move.w    6(a3,d4.l),n_replen(a6)    ; save replen
  1098.     moveq    #0,d0
  1099.     move.b    n_volume(a6),d0
  1100.     move.w    d0,8(a5)    ; set volume
  1101.     bra.s    mt_setregs
  1102.  
  1103. mt_noloop
  1104.     move.l    n_start(a6),d2
  1105.     add.l    d3,d2
  1106.     move.l    d2,n_loopstart(a6)
  1107.     move.l    d2,n_wavestart(a6)
  1108.     move.w    6(a3,d4.l),n_replen(a6)    ; save replen
  1109.     moveq    #0,d0
  1110.     move.b    n_volume(a6),d0
  1111.     move.w    d0,8(a5)    ; set volume
  1112. mt_setregs
  1113.     move.w    (a6),d0
  1114.     and.w    #$0fff,d0
  1115.     beq    mt_checkmoreefx    ; if no note
  1116.     move.w    2(a6),d0
  1117.     and.w    #$0ff0,d0
  1118.     cmp.w    #$0e50,d0
  1119.     beq.s    mt_dosetfinetune
  1120.     move.b    2(a6),d0
  1121.     and.b    #$0f,d0
  1122.     cmp.b    #3,d0    ; toneportamento
  1123.     beq.s    mt_chktoneporta
  1124.     cmp.b    #5,d0
  1125.     beq.s    mt_chktoneporta
  1126.     cmp.b    #9,d0    ; sample offset
  1127.     bne.s    mt_setperiod
  1128.     bsr    mt_checkmoreefx
  1129.     bra.s    mt_setperiod
  1130.  
  1131. mt_dosetfinetune
  1132.     bsr    mt_setfinetune
  1133.     bra.s    mt_setperiod
  1134.  
  1135. mt_chktoneporta
  1136.     bsr    mt_settoneporta
  1137.     bra    mt_checkmoreefx
  1138.  
  1139. mt_setperiod
  1140.     movem.l    d0-d1/a0-a1,-(sp)
  1141.     move.w    (a6),d1
  1142.     and.w    #$0fff,d1
  1143.     lea    mt_periodtable(pc),a1
  1144.     moveq    #0,d0
  1145.     moveq    #36,d2
  1146. mt_ftuloop
  1147.     cmp.w    (a1,d0.w),d1
  1148.     bhs.s    mt_ftufound
  1149.     addq.l    #2,d0
  1150.     dbra    d2,mt_ftuloop
  1151. mt_ftufound
  1152.     moveq    #0,d1
  1153.     move.b    n_finetune(a6),d1
  1154.     mulu    #36*2,d1
  1155.     add.l    d1,a1
  1156.     move.w    (a1,d0.w),n_period(a6)
  1157.     movem.l    (sp)+,d0-d1/a0-a1
  1158.  
  1159.     move.w    2(a6),d0
  1160.     and.w    #$0ff0,d0
  1161.     cmp.w    #$0ed0,d0 ; notedelay
  1162.     beq    mt_checkmoreefx
  1163.  
  1164.     move.w    n_dmabit(a6),$dff096
  1165.     btst    #2,n_wavecontrol(a6)
  1166.     bne.s    mt_vibnoc
  1167.     clr.b    n_vibratopos(a6)
  1168. mt_vibnoc
  1169.     btst    #6,n_wavecontrol(a6)
  1170.     bne.s    mt_trenoc
  1171.     clr.b    n_tremolopos(a6)
  1172. mt_trenoc
  1173.     move.l    n_start(a6),(a5)    ; set start
  1174.     move.w    n_length(a6),4(a5)    ; set length
  1175.     move.w    n_period(a6),d0
  1176.     move.w    d0,6(a5)        ; set period
  1177.     move.w    n_dmabit(a6),d0
  1178.     or.w    d0,mt_dmacontemp
  1179.     bra    mt_checkmoreefx
  1180.  
  1181. mt_setdma
  1182.     move    mt_dmadelay(pc),d0
  1183. mt_waitdma
  1184.     dbra    d0,mt_waitdma
  1185.     move.w    mt_dmacontemp(pc),d0
  1186.     or.w    #$8000,d0
  1187.     move.w    d0,$dff096
  1188.     move.w    #300,d0
  1189. mt_waitdma2
  1190.     dbra    d0,mt_waitdma2
  1191.  
  1192.     lea    $dff000,a5
  1193.     lea    mt_chan4temp(pc),a6
  1194.     move.l    n_loopstart(a6),$d0(a5)
  1195.     move.w    n_replen(a6),$d4(a5)
  1196.     lea    mt_chan3temp(pc),a6
  1197.     move.l    n_loopstart(a6),$c0(a5)
  1198.     move.w    n_replen(a6),$c4(a5)
  1199.     lea    mt_chan2temp(pc),a6
  1200.     move.l    n_loopstart(a6),$b0(a5)
  1201.     move.w    n_replen(a6),$b4(a5)
  1202.     lea    mt_chan1temp(pc),a6
  1203.     move.l    n_loopstart(a6),$a0(a5)
  1204.     move.w    n_replen(a6),$a4(a5)
  1205.  
  1206. mt_dskip
  1207.     add.w    #16,mt_patternpos
  1208.     move.b    mt_pattdeltime,d0
  1209.     beq.s    mt_dskc
  1210.     move.b    d0,mt_pattdeltime2
  1211.     clr.b    mt_pattdeltime
  1212. mt_dskc    tst.b    mt_pattdeltime2
  1213.     beq.s    mt_dska
  1214.     subq.b    #1,mt_pattdeltime2
  1215.     beq.s    mt_dska
  1216.     sub.w    #16,mt_patternpos
  1217. mt_dska    tst.b    mt_pbreakflag
  1218.     beq.s    mt_nnpysk
  1219.     sf    mt_pbreakflag
  1220.     moveq    #0,d0
  1221.     move.b    mt_pbreakpos(pc),d0
  1222.     clr.b    mt_pbreakpos
  1223.     lsl.w    #4,d0
  1224.     move.w    d0,mt_patternpos
  1225. mt_nnpysk
  1226.     cmp.w    #1024,mt_patternpos
  1227.     blo.s    mt_nonewposyet
  1228. mt_nextposition    
  1229.     moveq    #0,d0
  1230.     move.b    mt_pbreakpos(pc),d0
  1231.     lsl.w    #4,d0
  1232.     move.w    d0,mt_patternpos
  1233.     clr.b    mt_pbreakpos
  1234.     clr.b    mt_posjumpflag
  1235.     addq.b    #1,mt_songpos
  1236.     and.b    #$7f,mt_songpos
  1237.     move.b    mt_songpos(pc),d1
  1238.     move.l    mt_songdataptr(pc),a0
  1239.     cmp.b    950(a0),d1
  1240.     blo.s    mt_nonewposyet
  1241.     clr.b    mt_songpos
  1242. mt_nonewposyet    
  1243.     tst.b    mt_posjumpflag
  1244.     bne.s    mt_nextposition
  1245. mt_exit    movem.l    (sp)+,d0-d4/a0-a6
  1246.     rts
  1247.  
  1248. mt_checkefx
  1249.     bsr    mt_updatefunk
  1250.     move.w    n_cmd(a6),d0
  1251.     and.w    #$0fff,d0
  1252.     beq.s    mt_pernop
  1253.     move.b    n_cmd(a6),d0
  1254.     and.b    #$0f,d0
  1255.     beq.s    mt_arpeggio
  1256.     cmp.b    #1,d0
  1257.     beq    mt_portaup
  1258.     cmp.b    #2,d0
  1259.     beq    mt_portadown
  1260.     cmp.b    #3,d0
  1261.     beq    mt_toneportamento
  1262.     cmp.b    #4,d0
  1263.     beq    mt_vibrato
  1264.     cmp.b    #5,d0
  1265.     beq    mt_toneplusvolslide
  1266.     cmp.b    #6,d0
  1267.     beq    mt_vibratoplusvolslide
  1268.     cmp.b    #$e,d0
  1269.     beq    mt_e_commands
  1270. setback    move.w    n_period(a6),6(a5)
  1271.     cmp.b    #7,d0
  1272.     beq    mt_tremolo
  1273.     cmp.b    #$a,d0
  1274.     beq    mt_volumeslide
  1275. mt_return
  1276.     rts
  1277.  
  1278. mt_pernop
  1279.     move.w    n_period(a6),6(a5)
  1280.     rts
  1281.  
  1282. mt_arpeggio
  1283.     moveq    #0,d0
  1284.     move.b    mt_counter(pc),d0
  1285.     divs    #3,d0
  1286.     swap    d0
  1287.     cmp.w    #0,d0
  1288.     beq.s    mt_arpeggio2
  1289.     cmp.w    #2,d0
  1290.     beq.s    mt_arpeggio1
  1291.     moveq    #0,d0
  1292.     move.b    n_cmdlo(a6),d0
  1293.     lsr.b    #4,d0
  1294.     bra.s    mt_arpeggio3
  1295.  
  1296. mt_arpeggio1
  1297.     moveq    #0,d0
  1298.     move.b    n_cmdlo(a6),d0
  1299.     and.b    #15,d0
  1300.     bra.s    mt_arpeggio3
  1301.  
  1302. mt_arpeggio2
  1303.     move.w    n_period(a6),d2
  1304.     bra.s    mt_arpeggio4
  1305.  
  1306. mt_arpeggio3
  1307.     asl.w    #1,d0
  1308.     moveq    #0,d1
  1309.     move.b    n_finetune(a6),d1
  1310.     mulu    #36*2,d1
  1311.     lea    mt_periodtable(pc),a0
  1312.     add.l    d1,a0
  1313.     moveq    #0,d1
  1314.     move.w    n_period(a6),d1
  1315.     moveq    #36,d3
  1316. mt_arploop
  1317.     move.w    (a0,d0.w),d2
  1318.     cmp.w    (a0),d1
  1319.     bhs.s    mt_arpeggio4
  1320.     addq.l    #2,a0
  1321.     dbra    d3,mt_arploop
  1322.     rts
  1323.  
  1324. mt_arpeggio4
  1325.     move.w    d2,6(a5)
  1326.     rts
  1327.  
  1328. mt_fineportaup
  1329.     tst.b    mt_counter
  1330.     bne.s    mt_return
  1331.     move.b    #$0f,mt_lowmask
  1332. mt_portaup
  1333.     moveq    #0,d0
  1334.     move.b    n_cmdlo(a6),d0
  1335.     and.b    mt_lowmask(pc),d0
  1336.     move.b    #$ff,mt_lowmask
  1337.     sub.w    d0,n_period(a6)
  1338.     move.w    n_period(a6),d0
  1339.     and.w    #$0fff,d0
  1340.     cmp.w    #113,d0
  1341.     bpl.s    mt_portauskip
  1342.     and.w    #$f000,n_period(a6)
  1343.     or.w    #113,n_period(a6)
  1344. mt_portauskip
  1345.     move.w    n_period(a6),d0
  1346.     and.w    #$0fff,d0
  1347.     move.w    d0,6(a5)
  1348.     rts    
  1349.  
  1350. mt_fineportadown
  1351.     tst.b    mt_counter
  1352.     bne    mt_return
  1353.     move.b    #$0f,mt_lowmask
  1354. mt_portadown
  1355.     clr.w    d0
  1356.     move.b    n_cmdlo(a6),d0
  1357.     and.b    mt_lowmask(pc),d0
  1358.     move.b    #$ff,mt_lowmask
  1359.     add.w    d0,n_period(a6)
  1360.     move.w    n_period(a6),d0
  1361.     and.w    #$0fff,d0
  1362.     cmp.w    #856,d0
  1363.     bmi.s    mt_portadskip
  1364.     and.w    #$f000,n_period(a6)
  1365.     or.w    #856,n_period(a6)
  1366. mt_portadskip
  1367.     move.w    n_period(a6),d0
  1368.     and.w    #$0fff,d0
  1369.     move.w    d0,6(a5)
  1370.     rts
  1371.  
  1372. mt_settoneporta
  1373.     move.l    a0,-(sp)
  1374.     move.w    (a6),d2
  1375.     and.w    #$0fff,d2
  1376.     moveq    #0,d0
  1377.     move.b    n_finetune(a6),d0
  1378.     mulu    #37*2,d0
  1379.     lea    mt_periodtable(pc),a0
  1380.     add.l    d0,a0
  1381.     moveq    #0,d0
  1382. mt_stploop
  1383.     cmp.w    (a0,d0.w),d2
  1384.     bhs.s    mt_stpfound
  1385.     addq.w    #2,d0
  1386.     cmp.w    #37*2,d0
  1387.     blo.s    mt_stploop
  1388.     moveq    #35*2,d0
  1389. mt_stpfound
  1390.     move.b    n_finetune(a6),d2
  1391.     and.b    #8,d2
  1392.     beq.s    mt_stpgoss
  1393.     tst.w    d0
  1394.     beq.s    mt_stpgoss
  1395.     subq.w    #2,d0
  1396. mt_stpgoss
  1397.     move.w    (a0,d0.w),d2
  1398.     move.l    (sp)+,a0
  1399.     move.w    d2,n_wantedperiod(a6)
  1400.     move.w    n_period(a6),d0
  1401.     clr.b    n_toneportdirec(a6)
  1402.     cmp.w    d0,d2
  1403.     beq.s    mt_cleartoneporta
  1404.     bge    mt_return
  1405.     move.b    #1,n_toneportdirec(a6)
  1406.     rts
  1407.  
  1408. mt_cleartoneporta
  1409.     clr.w    n_wantedperiod(a6)
  1410.     rts
  1411.  
  1412. mt_toneportamento
  1413.     move.b    n_cmdlo(a6),d0
  1414.     beq.s    mt_toneportnochange
  1415.     move.b    d0,n_toneportspeed(a6)
  1416.     clr.b    n_cmdlo(a6)
  1417. mt_toneportnochange
  1418.     tst.w    n_wantedperiod(a6)
  1419.     beq    mt_return
  1420.     moveq    #0,d0
  1421.     move.b    n_toneportspeed(a6),d0
  1422.     tst.b    n_toneportdirec(a6)
  1423.     bne.s    mt_toneportaup
  1424. mt_toneportadown
  1425.     add.w    d0,n_period(a6)
  1426.     move.w    n_wantedperiod(a6),d0
  1427.     cmp.w    n_period(a6),d0
  1428.     bgt.s    mt_toneportasetper
  1429.     move.w    n_wantedperiod(a6),n_period(a6)
  1430.     clr.w    n_wantedperiod(a6)
  1431.     bra.s    mt_toneportasetper
  1432.  
  1433. mt_toneportaup
  1434.     sub.w    d0,n_period(a6)
  1435.     move.w    n_wantedperiod(a6),d0
  1436.     cmp.w    n_period(a6),d0
  1437.     blt.s    mt_toneportasetper
  1438.     move.w    n_wantedperiod(a6),n_period(a6)
  1439.     clr.w    n_wantedperiod(a6)
  1440.  
  1441. mt_toneportasetper
  1442.     move.w    n_period(a6),d2
  1443.     move.b    n_glissfunk(a6),d0
  1444.     and.b    #$0f,d0
  1445.     beq.s    mt_glissskip
  1446.     moveq    #0,d0
  1447.     move.b    n_finetune(a6),d0
  1448.     mulu    #36*2,d0
  1449.     lea    mt_periodtable(pc),a0
  1450.     add.l    d0,a0
  1451.     moveq    #0,d0
  1452. mt_glissloop
  1453.     cmp.w    (a0,d0.w),d2
  1454.     bhs.s    mt_glissfound
  1455.     addq.w    #2,d0
  1456.     cmp.w    #36*2,d0
  1457.     blo.s    mt_glissloop
  1458.     moveq    #35*2,d0
  1459. mt_glissfound
  1460.     move.w    (a0,d0.w),d2
  1461. mt_glissskip
  1462.     move.w    d2,6(a5) ; set period
  1463.     rts
  1464.  
  1465. mt_vibrato
  1466.     move.b    n_cmdlo(a6),d0
  1467.     beq.s    mt_vibrato2
  1468.     move.b    n_vibratocmd(a6),d2
  1469.     and.b    #$0f,d0
  1470.     beq.s    mt_vibskip
  1471.     and.b    #$f0,d2
  1472.     or.b    d0,d2
  1473. mt_vibskip
  1474.     move.b    n_cmdlo(a6),d0
  1475.     and.b    #$f0,d0
  1476.     beq.s    mt_vibskip2
  1477.     and.b    #$0f,d2
  1478.     or.b    d0,d2
  1479. mt_vibskip2
  1480.     move.b    d2,n_vibratocmd(a6)
  1481. mt_vibrato2
  1482.     move.b    n_vibratopos(a6),d0
  1483.     lea    mt_vibratotable(pc),a4
  1484.     lsr.w    #2,d0
  1485.     and.w    #$001f,d0
  1486.     moveq    #0,d2
  1487.     move.b    n_wavecontrol(a6),d2
  1488.     and.b    #$03,d2
  1489.     beq.s    mt_vib_sine
  1490.     lsl.b    #3,d0
  1491.     cmp.b    #1,d2
  1492.     beq.s    mt_vib_rampdown
  1493.     move.b    #255,d2
  1494.     bra.s    mt_vib_set
  1495. mt_vib_rampdown
  1496.     tst.b    n_vibratopos(a6)
  1497.     bpl.s    mt_vib_rampdown2
  1498.     move.b    #255,d2
  1499.     sub.b    d0,d2
  1500.     bra.s    mt_vib_set
  1501. mt_vib_rampdown2
  1502.     move.b    d0,d2
  1503.     bra.s    mt_vib_set
  1504. mt_vib_sine
  1505.     move.b    (a4,d0.w),d2
  1506. mt_vib_set
  1507.     move.b    n_vibratocmd(a6),d0
  1508.     and.w    #15,d0
  1509.     mulu    d0,d2
  1510.     lsr.w    #7,d2
  1511.     move.w    n_period(a6),d0
  1512.     tst.b    n_vibratopos(a6)
  1513.     bmi.s    mt_vibratoneg
  1514.     add.w    d2,d0
  1515.     bra.s    mt_vibrato3
  1516. mt_vibratoneg
  1517.     sub.w    d2,d0
  1518. mt_vibrato3
  1519.     move.w    d0,6(a5)
  1520.     move.b    n_vibratocmd(a6),d0
  1521.     lsr.w    #2,d0
  1522.     and.w    #$003c,d0
  1523.     add.b    d0,n_vibratopos(a6)
  1524.     rts
  1525.  
  1526. mt_toneplusvolslide
  1527.     bsr    mt_toneportnochange
  1528.     bra    mt_volumeslide
  1529.  
  1530. mt_vibratoplusvolslide
  1531.     bsr.s    mt_vibrato2
  1532.     bra    mt_volumeslide
  1533.  
  1534. mt_tremolo
  1535.     move.b    n_cmdlo(a6),d0
  1536.     beq.s    mt_tremolo2
  1537.     move.b    n_tremolocmd(a6),d2
  1538.     and.b    #$0f,d0
  1539.     beq.s    mt_treskip
  1540.     and.b    #$f0,d2
  1541.     or.b    d0,d2
  1542. mt_treskip
  1543.     move.b    n_cmdlo(a6),d0
  1544.     and.b    #$f0,d0
  1545.     beq.s    mt_treskip2
  1546.     and.b    #$0f,d2
  1547.     or.b    d0,d2
  1548. mt_treskip2
  1549.     move.b    d2,n_tremolocmd(a6)
  1550. mt_tremolo2
  1551.     move.b    n_tremolopos(a6),d0
  1552.     lea    mt_vibratotable(pc),a4
  1553.     lsr.w    #2,d0
  1554.     and.w    #$001f,d0
  1555.     moveq    #0,d2
  1556.     move.b    n_wavecontrol(a6),d2
  1557.     lsr.b    #4,d2
  1558.     and.b    #$03,d2
  1559.     beq.s    mt_tre_sine
  1560.     lsl.b    #3,d0
  1561.     cmp.b    #1,d2
  1562.     beq.s    mt_tre_rampdown
  1563.     move.b    #255,d2
  1564.     bra.s    mt_tre_set
  1565. mt_tre_rampdown
  1566.     tst.b    n_vibratopos(a6)
  1567.     bpl.s    mt_tre_rampdown2
  1568.     move.b    #255,d2
  1569.     sub.b    d0,d2
  1570.     bra.s    mt_tre_set
  1571. mt_tre_rampdown2
  1572.     move.b    d0,d2
  1573.     bra.s    mt_tre_set
  1574. mt_tre_sine
  1575.     move.b    (a4,d0.w),d2
  1576. mt_tre_set
  1577.     move.b    n_tremolocmd(a6),d0
  1578.     and.w    #15,d0
  1579.     mulu    d0,d2
  1580.     lsr.w    #6,d2
  1581.     moveq    #0,d0
  1582.     move.b    n_volume(a6),d0
  1583.     tst.b    n_tremolopos(a6)
  1584.     bmi.s    mt_tremoloneg
  1585.     add.w    d2,d0
  1586.     bra.s    mt_tremolo3
  1587. mt_tremoloneg
  1588.     sub.w    d2,d0
  1589. mt_tremolo3
  1590.     bpl.s    mt_tremoloskip
  1591.     clr.w    d0
  1592. mt_tremoloskip
  1593.     cmp.w    #$40,d0
  1594.     bls.s    mt_tremolook
  1595.     move.w    #$40,d0
  1596. mt_tremolook
  1597.     move.w    d0,8(a5)
  1598.     move.b    n_tremolocmd(a6),d0
  1599.     lsr.w    #2,d0
  1600.     and.w    #$003c,d0
  1601.     add.b    d0,n_tremolopos(a6)
  1602.     rts
  1603.  
  1604. mt_sampleoffset
  1605.     moveq    #0,d0
  1606.     move.b    n_cmdlo(a6),d0
  1607.     beq.s    mt_sononew
  1608.     move.b    d0,n_sampleoffset(a6)
  1609. mt_sononew
  1610.     move.b    n_sampleoffset(a6),d0
  1611.     lsl.w    #7,d0
  1612.     cmp.w    n_length(a6),d0
  1613.     bge.s    mt_sofskip
  1614.     sub.w    d0,n_length(a6)
  1615.     lsl.w    #1,d0
  1616.     add.l    d0,n_start(a6)
  1617.     rts
  1618. mt_sofskip
  1619.     move.w    #$0001,n_length(a6)
  1620.     rts
  1621.  
  1622. mt_volumeslide
  1623.     moveq    #0,d0
  1624.     move.b    n_cmdlo(a6),d0
  1625.     lsr.b    #4,d0
  1626.     tst.b    d0
  1627.     beq.s    mt_volslidedown
  1628. mt_volslideup
  1629.     add.b    d0,n_volume(a6)
  1630.     cmp.b    #$40,n_volume(a6)
  1631.     bmi.s    mt_vsuskip
  1632.     move.b    #$40,n_volume(a6)
  1633. mt_vsuskip
  1634.     move.b    n_volume(a6),d0
  1635.     move.w    d0,8(a5)
  1636.     rts
  1637.  
  1638. mt_volslidedown
  1639.     moveq    #0,d0
  1640.     move.b    n_cmdlo(a6),d0
  1641.     and.b    #$0f,d0
  1642. mt_volslidedown2
  1643.     sub.b    d0,n_volume(a6)
  1644.     bpl.s    mt_vsdskip
  1645.     clr.b    n_volume(a6)
  1646. mt_vsdskip
  1647.     move.b    n_volume(a6),d0
  1648.     move.w    d0,8(a5)
  1649.     rts
  1650.  
  1651. mt_positionjump
  1652.     move.b    n_cmdlo(a6),d0
  1653.     subq.b    #1,d0
  1654.     move.b    d0,mt_songpos
  1655. mt_pj2    clr.b    mt_pbreakpos
  1656.     st     mt_posjumpflag
  1657.     rts
  1658.  
  1659. mt_volumechange
  1660.     moveq    #0,d0
  1661.     move.b    n_cmdlo(a6),d0
  1662.     cmp.b    #$40,d0
  1663.     bls.s    mt_volumeok
  1664.     moveq    #$40,d0
  1665. mt_volumeok
  1666.     move.b    d0,n_volume(a6)
  1667.     move.w    d0,8(a5)
  1668.     rts
  1669.  
  1670. mt_patternbreak
  1671.     moveq    #0,d0
  1672.     move.b    n_cmdlo(a6),d0
  1673.     move.l    d0,d2
  1674.     lsr.b    #4,d0
  1675.     mulu    #10,d0
  1676.     and.b    #$0f,d2
  1677.     add.b    d2,d0
  1678.     cmp.b    #63,d0
  1679.     bhi.s    mt_pj2
  1680.     move.b    d0,mt_pbreakpos
  1681.     st    mt_posjumpflag
  1682.     rts
  1683.  
  1684. mt_setspeed
  1685.     moveq    #0,d0
  1686.     move.b    3(a6),d0
  1687.     beq    mt_end
  1688.     cmp.b    #32,d0
  1689.     bhs    settempo
  1690.     clr.b    mt_counter
  1691.     move.b    d0,mt_speed
  1692.     rts
  1693.  
  1694. mt_checkmoreefx
  1695.     bsr    mt_updatefunk
  1696.     move.b    2(a6),d0
  1697.     and.b    #$0f,d0
  1698.     cmp.b    #$9,d0
  1699.     beq    mt_sampleoffset
  1700.     cmp.b    #$b,d0
  1701.     beq    mt_positionjump
  1702.     cmp.b    #$d,d0
  1703.     beq.s    mt_patternbreak
  1704.     cmp.b    #$e,d0
  1705.     beq.s    mt_e_commands
  1706.     cmp.b    #$f,d0
  1707.     beq.s    mt_setspeed
  1708.     cmp.b    #$c,d0
  1709.     beq    mt_volumechange
  1710.     bra    mt_pernop
  1711.  
  1712. mt_e_commands
  1713.     move.b    n_cmdlo(a6),d0
  1714.     and.b    #$f0,d0
  1715.     lsr.b    #4,d0
  1716.     beq.s    mt_filteronoff
  1717.     cmp.b    #1,d0
  1718.     beq    mt_fineportaup
  1719.     cmp.b    #2,d0
  1720.     beq    mt_fineportadown
  1721.     cmp.b    #3,d0
  1722.     beq.s    mt_setglisscontrol
  1723.     cmp.b    #4,d0
  1724.     beq    mt_setvibratocontrol
  1725.     cmp.b    #5,d0
  1726.     beq    mt_setfinetune
  1727.     cmp.b    #6,d0
  1728.     beq    mt_jumploop
  1729.     cmp.b    #7,d0
  1730.     beq    mt_settremolocontrol
  1731.     cmp.b    #9,d0
  1732.     beq    mt_retrignote
  1733.     cmp.b    #$a,d0
  1734.     beq    mt_volumefineup
  1735.     cmp.b    #$b,d0
  1736.     beq    mt_volumefinedown
  1737.     cmp.b    #$c,d0
  1738.     beq    mt_notecut
  1739.     cmp.b    #$d,d0
  1740.     beq    mt_notedelay
  1741.     cmp.b    #$e,d0
  1742.     beq    mt_patterndelay
  1743.     cmp.b    #$f,d0
  1744.     beq    mt_funkit
  1745.     rts
  1746.  
  1747. mt_filteronoff
  1748.     move.b    n_cmdlo(a6),d0
  1749.     and.b    #1,d0
  1750.     asl.b    #1,d0
  1751.     and.b    #$fd,$bfe001
  1752.     or.b    d0,$bfe001
  1753.     rts    
  1754.  
  1755. mt_setglisscontrol
  1756.     move.b    n_cmdlo(a6),d0
  1757.     and.b    #$0f,d0
  1758.     and.b    #$f0,n_glissfunk(a6)
  1759.     or.b    d0,n_glissfunk(a6)
  1760.     rts
  1761.  
  1762. mt_setvibratocontrol
  1763.     move.b    n_cmdlo(a6),d0
  1764.     and.b    #$0f,d0
  1765.     and.b    #$f0,n_wavecontrol(a6)
  1766.     or.b    d0,n_wavecontrol(a6)
  1767.     rts
  1768.  
  1769. mt_setfinetune
  1770.     move.b    n_cmdlo(a6),d0
  1771.     and.b    #$0f,d0
  1772.     move.b    d0,n_finetune(a6)
  1773.     rts
  1774.  
  1775. mt_jumploop
  1776.     tst.b    mt_counter
  1777.     bne    mt_return
  1778.     move.b    n_cmdlo(a6),d0
  1779.     and.b    #$0f,d0
  1780.     beq.s    mt_setloop
  1781.     tst.b    n_loopcount(a6)
  1782.     beq.s    mt_jumpcnt
  1783.     subq.b    #1,n_loopcount(a6)
  1784.     beq    mt_return
  1785. mt_jmploop    move.b    n_pattpos(a6),mt_pbreakpos
  1786.     st    mt_pbreakflag
  1787.     rts
  1788.  
  1789. mt_jumpcnt
  1790.     move.b    d0,n_loopcount(a6)
  1791.     bra.s    mt_jmploop
  1792.  
  1793. mt_setloop
  1794.     move.w    mt_patternpos(pc),d0
  1795.     lsr.w    #4,d0
  1796.     move.b    d0,n_pattpos(a6)
  1797.     rts
  1798.  
  1799. mt_settremolocontrol
  1800.     move.b    n_cmdlo(a6),d0
  1801.     and.b    #$0f,d0
  1802.     lsl.b    #4,d0
  1803.     and.b    #$0f,n_wavecontrol(a6)
  1804.     or.b    d0,n_wavecontrol(a6)
  1805.     rts
  1806.  
  1807. mt_retrignote
  1808.     move.l    d1,-(sp)
  1809.     moveq    #0,d0
  1810.     move.b    n_cmdlo(a6),d0
  1811.     and.b    #$0f,d0
  1812.     beq.s    mt_rtnend
  1813.     moveq    #0,d1
  1814.     move.b    mt_counter(pc),d1
  1815.     bne.s    mt_rtnskp
  1816.     move.w    (a6),d1
  1817.     and.w    #$0fff,d1
  1818.     bne.s    mt_rtnend
  1819.     moveq    #0,d1
  1820.     move.b    mt_counter(pc),d1
  1821. mt_rtnskp
  1822.     divu    d0,d1
  1823.     swap    d1
  1824.     tst.w    d1
  1825.     bne.s    mt_rtnend
  1826. mt_doretrig
  1827.     move.w    n_dmabit(a6),$dff096    ; channel dma off
  1828.     move.l    n_start(a6),(a5)    ; set sampledata pointer
  1829.     move.w    n_length(a6),4(a5)    ; set length
  1830.     move.w    #300,d0
  1831. mt_rtnloop1
  1832.     dbra    d0,mt_rtnloop1
  1833.     move.w    n_dmabit(a6),d0
  1834.     bset    #15,d0
  1835.     move.w    d0,$dff096
  1836.     move.w    #300,d0
  1837. mt_rtnloop2
  1838.     dbra    d0,mt_rtnloop2
  1839.     move.l    n_loopstart(a6),(a5)
  1840.     move.l    n_replen(a6),4(a5)
  1841. mt_rtnend
  1842.     move.l    (sp)+,d1
  1843.     rts
  1844.  
  1845. mt_volumefineup
  1846.     tst.b    mt_counter
  1847.     bne    mt_return
  1848.     moveq    #0,d0
  1849.     move.b    n_cmdlo(a6),d0
  1850.     and.b    #$f,d0
  1851.     bra    mt_volslideup
  1852.  
  1853. mt_volumefinedown
  1854.     tst.b    mt_counter
  1855.     bne    mt_return
  1856.     moveq    #0,d0
  1857.     move.b    n_cmdlo(a6),d0
  1858.     and.b    #$0f,d0
  1859.     bra    mt_volslidedown2
  1860.  
  1861. mt_notecut
  1862.     moveq    #0,d0
  1863.     move.b    n_cmdlo(a6),d0
  1864.     and.b    #$0f,d0
  1865.     cmp.b    mt_counter(pc),d0
  1866.     bne    mt_return
  1867.     clr.b    n_volume(a6)
  1868.     move.w    #0,8(a5)
  1869.     rts
  1870.  
  1871. mt_notedelay
  1872.     moveq    #0,d0
  1873.     move.b    n_cmdlo(a6),d0
  1874.     and.b    #$0f,d0
  1875.     cmp.b    mt_counter,d0
  1876.     bne    mt_return
  1877.     move.w    (a6),d0
  1878.     beq    mt_return
  1879.     move.l    d1,-(sp)
  1880.     bra    mt_doretrig
  1881.  
  1882. mt_patterndelay
  1883.     tst.b    mt_counter
  1884.     bne    mt_return
  1885.     moveq    #0,d0
  1886.     move.b    n_cmdlo(a6),d0
  1887.     and.b    #$0f,d0
  1888.     tst.b    mt_pattdeltime2
  1889.     bne    mt_return
  1890.     addq.b    #1,d0
  1891.     move.b    d0,mt_pattdeltime
  1892.     rts
  1893.  
  1894. mt_funkit
  1895.     tst.b    mt_counter
  1896.     bne    mt_return
  1897.     move.b    n_cmdlo(a6),d0
  1898.     and.b    #$0f,d0
  1899.     lsl.b    #4,d0
  1900.     and.b    #$0f,n_glissfunk(a6)
  1901.     or.b    d0,n_glissfunk(a6)
  1902.     tst.b    d0
  1903.     beq    mt_return
  1904. mt_updatefunk
  1905.     movem.l    a0/d1,-(sp)
  1906.     moveq    #0,d0
  1907.     move.b    n_glissfunk(a6),d0
  1908.     lsr.b    #4,d0
  1909.     beq.s    mt_funkend
  1910.     lea    mt_funktable(pc),a0
  1911.     move.b    (a0,d0.w),d0
  1912.     add.b    d0,n_funkoffset(a6)
  1913.     btst    #7,n_funkoffset(a6)
  1914.     beq.s    mt_funkend
  1915.     clr.b    n_funkoffset(a6)
  1916.  
  1917.     move.l    n_loopstart(a6),d0
  1918.     moveq    #0,d1
  1919.     move.w    n_replen(a6),d1
  1920.     add.l    d1,d0
  1921.     add.l    d1,d0
  1922.     move.l    n_wavestart(a6),a0
  1923.     addq.l    #1,a0
  1924.     cmp.l    d0,a0
  1925.     blo.s    mt_funkok
  1926.     move.l    n_loopstart(a6),a0
  1927. mt_funkok
  1928.     move.l    a0,n_wavestart(a6)
  1929.     moveq    #-1,d0
  1930.     sub.b    (a0),d0
  1931.     move.b    d0,(a0)
  1932. mt_funkend
  1933.     movem.l    (sp)+,a0/d1
  1934.     rts
  1935.  
  1936.  
  1937. mt_funktable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  1938.  
  1939. mt_vibratotable    
  1940.     dc.b   0, 24, 49, 74, 97,120,141,161
  1941.     dc.b 180,197,212,224,235,244,250,253
  1942.     dc.b 255,253,250,244,235,224,212,197
  1943.     dc.b 180,161,141,120, 97, 74, 49, 24
  1944.  
  1945. mt_periodtable
  1946. ; tuning 0, normal
  1947.     dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  1948.     dc.w    428,404,381,360,339,320,302,285,269,254,240,226
  1949.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1950. ; tuning 1
  1951.     dc.w    850,802,757,715,674,637,601,567,535,505,477,450
  1952.     dc.w    425,401,379,357,337,318,300,284,268,253,239,225
  1953.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1954. ; tuning 2
  1955.     dc.w    844,796,752,709,670,632,597,563,532,502,474,447
  1956.     dc.w    422,398,376,355,335,316,298,282,266,251,237,224
  1957.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1958. ; tuning 3
  1959.     dc.w    838,791,746,704,665,628,592,559,528,498,470,444
  1960.     dc.w    419,395,373,352,332,314,296,280,264,249,235,222
  1961.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1962. ; tuning 4
  1963.     dc.w    832,785,741,699,660,623,588,555,524,495,467,441
  1964.     dc.w    416,392,370,350,330,312,294,278,262,247,233,220
  1965.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1966. ; tuning 5
  1967.     dc.w    826,779,736,694,655,619,584,551,520,491,463,437
  1968.     dc.w    413,390,368,347,328,309,292,276,260,245,232,219
  1969.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1970. ; tuning 6
  1971.     dc.w    820,774,730,689,651,614,580,547,516,487,460,434
  1972.     dc.w    410,387,365,345,325,307,290,274,258,244,230,217
  1973.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1974. ; tuning 7
  1975.     dc.w    814,768,725,684,646,610,575,543,513,484,457,431
  1976.     dc.w    407,384,363,342,323,305,288,272,256,242,228,216
  1977.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1978. ; tuning -8
  1979.     dc.w    907,856,808,762,720,678,640,604,570,538,508,480
  1980.     dc.w    453,428,404,381,360,339,320,302,285,269,254,240
  1981.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1982. ; tuning -7
  1983.     dc.w    900,850,802,757,715,675,636,601,567,535,505,477
  1984.     dc.w    450,425,401,379,357,337,318,300,284,268,253,238
  1985.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1986. ; tuning -6
  1987.     dc.w    894,844,796,752,709,670,632,597,563,532,502,474
  1988.     dc.w    447,422,398,376,355,335,316,298,282,266,251,237
  1989.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1990. ; tuning -5
  1991.     dc.w    887,838,791,746,704,665,628,592,559,528,498,470
  1992.     dc.w    444,419,395,373,352,332,314,296,280,264,249,235
  1993.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1994. ; tuning -4
  1995.     dc.w    881,832,785,741,699,660,623,588,555,524,494,467
  1996.     dc.w    441,416,392,370,350,330,312,294,278,262,247,233
  1997.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1998. ; tuning -3
  1999.     dc.w    875,826,779,736,694,655,619,584,551,520,491,463
  2000.     dc.w    437,413,390,368,347,328,309,292,276,260,245,232
  2001.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  2002. ; tuning -2
  2003.     dc.w    868,820,774,730,689,651,614,580,547,516,487,460
  2004.     dc.w    434,410,387,365,345,325,307,290,274,258,244,230
  2005.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  2006. ; tuning -1
  2007.     dc.w    862,814,768,725,684,646,610,575,543,513,484,457
  2008.     dc.w    431,407,384,363,342,323,305,288,272,256,242,228
  2009.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  2010.  
  2011. mt_chan1temp    dc.l    0,0,0,0,0,$00010000,0,  0,0,0,0
  2012. mt_chan2temp    dc.l    0,0,0,0,0,$00020000,0,  0,0,0,0
  2013. mt_chan3temp    dc.l    0,0,0,0,0,$00040000,0,  0,0,0,0
  2014. mt_chan4temp    dc.l    0,0,0,0,0,$00080000,0,  0,0,0,0
  2015.  
  2016. mt_samplestarts    dc.l    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2017.         dc.l    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  2018.  
  2019. mt_songdataptr    dc.l 0
  2020. mt_speed    dc.b 6
  2021. mt_counter    dc.b 0
  2022. mt_songpos    dc.b 0
  2023. mt_pbreakpos    dc.b 0
  2024. mt_posjumpflag    dc.b 0
  2025. mt_pbreakflag    dc.b 0
  2026. mt_lowmask    dc.b 0
  2027. mt_pattdeltime    dc.b 0
  2028. mt_pattdeltime2    dc.b 0
  2029. mt_enable    dc.b 0
  2030. mt_patternpos    dc.w 0
  2031. mt_dmacontemp    dc.w 0
  2032. mt_dmadelay    dc.w 800
  2033.  
  2034.